import Vue from 'vue'
import Vuex from 'vuex'
import user from '@/store/modules/user'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    title:'hahah666',
    newdata: 6,
    count: 5,
    content: '666我的宝贝'
  },
  getters: {
    plus(state){
      return state.newdata + state.count
    }
  },
  mutations: {
    addCount(state, obj) {
      state.count = state.count + obj.num
    },
    chang(state,num){
      state.count = num
    },
    add10(state, num){
      state.count += num
    }
  },
  actions: {
    // 实现定时器的效果 需要写在 actions 中
    seTimer(context, num) {
      setTimeout(() => {
        context.commit('add10',num)
      }, 1000)
    }
  },
  modules: {
    user
  }
})
